﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;

namespace iShare.Common.Layouts.AjaxServices
{
    /// <summary>
    /// 
    /// </summary>
    public class AjaxServicesBase : IHttpHandler
    {
        public void SendAjaxResult(HttpContext context, AjaxResult result)
        {
            context.Response.ContentType = "text/x-json";
            //context.Response.CacheControl = result.ResultCacheSecends == 0 ? "No-Cache" : "Max-Age=" + result.ResultCacheSecends;
            context.Response.CacheControl = "No-Cache";
         
            context.Response.Write((new JavaScriptSerializer()).Serialize(result));
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        public virtual void ProcessRequest(HttpContext context)
        {
        }
    }
}